<style>
.layui-input-block{
margin-left:120px;
}
</style>
<!-- start form -->
<form class="layui-form" action="" id="orderEditForm">

<div class="layui-row"  style="margin-top:10px;">
<!--  <input type="hidden" class="layui-input" name="id" value="" lay-verify="required"> -->
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">姓名：</label>
        <div class="layui-input-block" style="width:200px;">
            <input type="text" class="layui-input" name="name" lay-verify="required">
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">用户角色：</label>
        <div class="layui-input-block" style="width:200px;">
            <select  name="roleId" id="roleId" lay-verify="required" >
                <option th:each="roleOne:${roleList}" th:value="${roleOne.id}" th:text="${roleOne.name}" ></option>
            </select>
        </div>
    </div>
    </div>

	<div class="layui-row"  style="margin-top:10px;">
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">所属公司：</label>
        <div class="layui-input-block" style="width:200px;">
            <select  name="companyId" id="companyId" lay-verify="required" lay-filter="companyId">
            <option value="-1">请选择公司</option>
            <option th:each="ec:${actCenterCompanyMap}" th:attr="value=${ec.id}" th:text="${ec.name}">
<!--                 <option th:each="ec:${@redisHelper.getActCenterCompany(session.userCompanyId)}" th:value="${ec.id}" th:text="${ec.name}"></option> -->
            </select>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">部门：</label>
        <div class="layui-input-block" style="width:200px;">
            <select  name="departmentId" id="departmentId" lay-verify="required">
<!--             	<option th:each="ec:${dept}" th:attr="value=${ec.id}" th:text="${ec.name}" > -->
            </select>
        </div>
    </div>
    </div>

<div class="layui-row"  style="margin-top:10px;">
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">员工编号：</label>
        <div class="layui-input-block" style="width:200px;">
            <input type="text" class="layui-input" name="no"  lay-verify="required">
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">联系电话：</label>
        <div class="layui-input-block" style="width:200px;">
            <input type="text" class="layui-input" name="phone"  lay-verify="phone|required">
        </div>
    </div>
   </div>
   <div class="layui-row"  style="margin-top:10px;">
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">邮箱：</label>
        <div class="layui-input-block" style="width:200px;">
            <input type="text" class="layui-input" name="email"  lay-verify="email|required">
        </div>
    </div>
   
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">职务：</label>
        <div class="layui-input-block" style="width:200px;">
         <input type="text" class="layui-input" name="post"  lay-verify="required">
<!--             <select name="status" > -->
<!--                 <option th:value="1">正常</option> -->
<!--                 <option th:value="0">停用</option> -->
<!--             </select> -->
        </div>
    </div>
 </div>
 	 <div class="layui-row"  style="margin-top:10px;">
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
        <label class="layui-form-label" style="width:120px;">备注：</label>
        <div class="layui-input-block">
            <textarea  class="layui-textarea"   style="min-height: 50px;" name="remark" ></textarea>
        </div>
    </div>
    </div>


<div class="layui-row" style="margin-top:20px;">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="text-align:center;">
          <button class="layui-btn" lay-submit="" lay-filter="formSubmit" authcode='900023'>提交</button>
      	<button type="button" class="layui-btn layui-btn-primary" id="closeBtn">关闭</button>
    </div>
  </div>
</form>
<!-- end form -->
<script>
layui.use('form',function() {
	var form = layui.form;
	form.render();
	//表单提交监听
	form.on('submit(formSubmit)',function(data) {
		 $.ajax({url:'/com/staff/add',
				data:$("#orderEditForm").serializeJson(),
				type:"get",
				contentType:"application/json",
				success:function(data){
					if(data.code==200){
						layer.msg("数据保存成功！");
						layer.closeAll();
					}else{
						layer.msg(data.message);
					}
				}});
			return false;
	});
	//监听select
	form.on('select(companyId)',function(data) {
		companyId = data.value;//被选中的值
		console.log("companyId="+companyId);
		if(companyId == -1) {
			layer.msg("请选择公司");
			return false;
		}
		//获取部门信息
		$.getJSON("/com/supplier/customer/getDeptById?companyId="+data.value,function(dataList) {
				 var html = [];
				  html.push("<option value=''>请选择分管部门</option>")
				  $.each(dataList,function(i,item){
					  html.push("<option value='"+item.id+"'>"+item.name+"</option>")
				  });
				  $("select[name='departmentId']").html(html.join(""));
	              form.render('select');
			
		});
	});
	//关闭
	$("#closeBtn").click(function() {
		layer.closeAll();
	});
});
</script>